import { BasicColumn, FormSchema } from '@/components/Table';
import { h, ref } from 'vue';
import { Tag } from 'ant-design-vue';
import {VxeFormItemProps, VxeGridPropTypes} from "@/components/VxeTable";
import util from "@/utils/util";
import { postRequestAll } from '@/api/sys/sysData';


//表格列名
export const columns: BasicColumn[] = [
  {
    title: '用户名',
    dataIndex: 'userName',
    width: 130,

  },
  {
    title: '试卷名称',
    dataIndex: 'paperName',
  },
  {
    title: '得分',
    dataIndex: 'score',
    width: 130,
  },
  {
    title: '创建时间',
    width: 160,
    dataIndex: 'createTime',
  },
  {
    title: '交卷时间',
    width: 160,
    dataIndex: 'endTime',
  },

];


/**
 */
export const vxeTableColumns: VxeGridPropTypes.Columns = [
  {
    title: '用户id',
    field: 'userId',
    showOverflow: 'title',
    width: 120,
    align: 'center',
  },
  {
    title: '姓名',
    field: 'userName',
    showOverflow: 'title',
    width: 80,
    align: 'center',
  },

  {
    title: '性别',
    field: 'gender',
    align: 'center',
    width: 80,
  },
  {
    title: '是否有调岗记录',
    field: 'gender',
    align: 'center',
    slots:{
      default({row}) {
        let color="",text="";
          if(row.izChange==1){
            text="有";
            color="green";
          }else{
            text="无";
          }
          return h(Tag,{color},text)
      },
    },
    width: 80,
  },
  {
    title: '一级部门',
    field: 'deptName1',
    align: 'center',
    width: 100,
  },
  {
    title: '二级部门',
    field: 'deptName2',
    align: 'center',
    width: 100,
  },
  {
    title: '钉钉职位',
    field: 'roleName',
    align: 'center',
    width: 80,
  },
  {
    title: '人员类型',
    field: 'type',
    align: 'center',
    width: 80,
  },
  {
    title: '岗位部门',
    field: 'postDeptName',
    align: 'center',
    width: 100,
  },
  {
    title: '担任岗位',
    field: 'postRoleName',
    align: 'center',
    width: 100,
  },
  {
    title: '出生日期',
    width: 100,
    field: 'birthdate',
    align: 'center',
    formatter: ({ cellValue, row, column }) =>
      `${cellValue ? util.formatDate(new Date(cellValue)) : ''}`,
  },
  {
    title: '年龄',
    field: 'yearNum',
    align: 'center',
    width: 90,
  },
  {
    title: '入司日期',
    width: 100,
    field: 'addTime',
    align: 'center',
    formatter: ({ cellValue, row, column }) =>
      `${cellValue ? util.formatDate(new Date(cellValue)) : ''}`,
  },

  {
    title: '司龄',
    field: 'workNum',
    align: 'center',
    width: 90,
  },

  {
    title: '工作统计时间节点',
    width: 100,
    field: 'firstWordTime',
    align: 'center',
    formatter: ({ cellValue, row, column }) =>
      `${cellValue ? util.formatDate(new Date(cellValue)) : ''}`,
   },
  {
    title: '参考工作经验',
    field: 'workYear',
    align: 'center',
    width: 90,
  },
  {
    title: '工龄',
    field: 'firstWordNum',
    align: 'center',
    width: 90,
  },
  {
    title: '管理统计时间节点',
    field: 'firstManageTime',
    align: 'center',
    formatter: ({ cellValue, row, column }) =>
      `${cellValue ? util.formatDate(new Date(cellValue)) : ''}`,
    width: 90,
  },
  {
    title: '管理经验参考年限',
    field: 'manageYear',
    align: 'center',
    width: 90,
  },
  {
    title: '管理经验',
    field: 'firstManageNum',
    align: 'center',
    width: 90,
  },
  {
    title: '岗位统计时间节点',
    field: 'firstPostTime',
    formatter: ({ cellValue, row, column }) =>
      `${cellValue ? util.formatDate(new Date(cellValue)) : ''}`,
    align: 'center',
    width: 90,
  },
  {
    title: '专业经验参考年限',
    field: 'specialtyYear',
    align: 'center',
    width: 90,
  },
  {
    title: '专业经验',
    field: 'firstPostNum',
    align: 'center',
    width: 90,
  },
  {
    title: '专业',
    field: 'specialty',
    align: 'center',
    width: 100,
  },
  {
    title: '专业相符',
    field: 'specialtyMatching',
    align: 'center',
    width: 100,
  },

  {
    title: '学历',
    field: 'education',
    align: 'center',
    width: 90,
  },
  {
    title: '备注',
    field: 'remark',
    align: 'center',
    width: 90,
  },
  {
    title: '创建时间',
    field: 'createTime',
    width: 130,
    align: 'center',
  },
  {
    title: '更新时间',
    field: 'updateTime',
    width: 130,
    align: 'center',
  },
  {
    width: 120,
    title: '操作',
    align: 'center',
    field: '',
    slots: { default: 'action' },
    fixed: 'right',
  },
];


export const searchFormSchema: FormSchema[] = [
  {
    field: 'userName',
    label: '姓名',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'paperName',
    label: '试卷名称',
    component: 'Input',
    colProps: { span: 8 },
  },

];


export const vxeTableFormSchema: VxeFormItemProps[] = [
  {
    span: 5,
    field: 'keyword',
    title: '查询',
    itemRender: {
      props: {
        placeholder: '姓名/岗位',
      },
      name: 'AInput',
    },
  },

  {
    span: 5,
    itemRender: {
      name: 'VxeButtonGroup',
      options: [
        { type: 'reset', content: '重置' },
        { type: 'submit', content: '查询', status: 'primary' },
      ],
    },
  },
];


export const formSchema: FormSchema[] = [
  {
    field: 'userInfo',
    label: '个人信息',
    slot: 'userInfo',
    colProps: { lg: 24, md: 24 },
  },
  {
    field: 'type',
    label: '人员类型',
    component:"Select",
    componentProps: {
          options: [
            { label: '管理人员', value: '管理人员' },
            { label: '技术人员', value: '技术人员' },
            { label: '其他人员', value: '其他人员' },
          ],
    },
    required: true,
  },
  {
    field: 'postRequestId',
    label: '任职岗位',

    slot:"postRequestId",

    // component:"ApiSelect",
    // componentProps: {
    //   api: postRequestAll,
    //   // mode:"multiple",
    //   resultField:"data",
    //   labelField: 'value',
    //   valueField: 'postRequestId',
    // },
    helpMessage:"用于任职资格评判的重要依据！",
    required: false,
  },
  {
    field: 'specialty',
    label: '专业',
    component:"Input",
    required: false,
  },
  {
    field: 'specialtyMatching',
    label: '专业相符',
    component:"Select",
    componentProps:{
      options: [
        {label:"相符",value:"相符"},
        {label:"相近",value:"相近"},
        {label:"不相符",value:"不相符"}
      ]
    },
    required: false,
  },

  {
    field: 'firstWordTime',
    label: '工作统计时间节点',
    component:"DatePicker",
    componentProps: {
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    required: false,
  },
  {
    field: 'workYear',
    label: '工作经验参考年限',
    helpMessage:"工作经验= 当前时间 -工作统计时间节点 + 线下统计的工作经验参考年限",
    component:"Input",
    required: false,
  },
  {
    field: 'education',
    label: '学历',
    component:"Input",
    required: false,
  },
  {
    field: 'firstManageTime',
    label: '管理统计时间节点',
    component:"DatePicker",
    componentProps: {
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    required: false,
  },
  {
    field: 'manageYear',
    label: '管理经验参考年限',
    helpMessage:"管理经验= (当前时间-工作统计时间节点)+管理经验参考年限；",
    component:"Input",
    required: false,
  },
  {
    field: 'firstPostTime',
    label: '岗位统计时间节点',
    component:"DatePicker",
    componentProps: {
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    required: false,
  },
  {
    field: 'specialtyYear',
    label: '专业经验参考年限',
    helpMessage:"专业作经验= (当前时间-专业统计时间节点)+专业经验参考年限",
    component:"Input",
    required: false,
  },
  {
    field: 'izChange',
    label: 'izChange',
  },
  {
    field: 'remark',
    label: '备注',
    component:"Input",
    required: false,
  },
  {
    field: 'specialtyYearLog',
    label: '专业记录档案',
    component:"InputTextArea",
    required: false,
  },
  {
    field: 'manageYearLog',
    label: '管理记录档案',
    component:"InputTextArea",
    required: false,
  },
  {
    field: 'workYearLog',
    label: '工作记录档案',
    component:"InputTextArea",
    required: false,
  },
  {
    field: 'items',
    label: '调岗记录',
    slot: 'items',
    ifShow: ({values}) => {
      return  values.izChange == 1
    },
    colProps: { lg: 24, md: 24 },
  },
  {
    field: 'satisfactions',
    label: '历史业绩',
    slot: 'satisfactions',
    colProps: { lg: 24, md: 24 },
  },

];


/**
 * 调岗记录
 */
export const teamUserColumns: VxeGridPropTypes.Columns = [
  {
    title: '姓名',
    field: 'userName',
    showOverflow: 'title',
    align: 'center',
    width: 120,
  },
  {
    title: '标题',
    field: 'title',
    showOverflow: 'title',
    align: 'center',
    // width: 150,
  },
  {
    title: '审批结果',
    field: 'result',
    showOverflow: 'title',
    align: 'center',
    slots:{
      default({row}) {
        let color="",text="";
        if(row.result=='agree'){
          text="同意";
          color="green";
        }else{
          text=row.result;
        }
        return h(Tag,{color},text)
      },
    },
    width: 80,
  },
  {
    title: '审批编号',
    field: 'approveNo',
    showOverflow: 'title',
    align: 'center',
    width: 150,
  },
  {
    title: '发起时间',
    field: 'addTime',
    showOverflow: 'title',
    align: 'center',
    width: 120,
  },
  {
    title: '原职位',
    field: 'original_post',
    showOverflow: 'title',
    align: 'center',
    width: 120,
  },
  {
    title: '转入职位',
    field: 'now_post',
    showOverflow: 'title',
    align: 'center',
    width: 120,
  },
  // {
  //   width: 120,
  //   title: '操作',
  //   align: 'center',
  //   field: '',
  //   slots: { default: 'action' },
  //   fixed: 'right',
  // },
  ]


/**
 * 满意度记录
 */
export const satisfactionColumns: VxeGridPropTypes.Columns = [
  {
    title: 'satisfactionMainId',
    field: 'satisfactionMainId',
    visible:false,
  },
  {
    title: '满意度',
    field: 'level',
    align: 'center',
    editRender:{
      name:"VxeSelect",
      options:[
        {label:"不太满意",value:"不太满意"},
        {label:"基本满意",value:"基本满意"},
        {label:"满意",value:"满意"},
        {label:"很满意",value:"很满意"},
      ]
    },
    width: 150,

  },

  {
    title: '年份',
    field: 'year',
    align: 'center',
    editRender:{
      name:"VxeDatePicker",
      props:{
        type:"year"
      }
    },
    width: 150,
  },
  {
    title: '明细',
    field: 'note',
    showOverflow: 'title',
    // align: 'center',
    editRender:{
      name:"VxeTextarea"

    },
  },
  {
    width: 80,
    title: '操作',
    align: 'center',
    field: '',
    slots: { default: 'action' },
    fixed: 'right',
  },

]
